<template>
  <div class="app-container">
    <el-row :gutter="10">
      <!--树结构-->
      <el-col :span="isHide ? 1 : 6" :xs="24" class="relative">
        <div class="app-container-tree-border">
          <project-tree-select-inner class="cd-mb8" :projectId="projectId" @changeProject="changeProject" />
          <el-tree :data="treeList" :props="defaultProps" ref="tree" node-key="id" highlight-current
            @node-click="handleNodeClick">
            <div slot-scope="{ node, data }" class="custom-tree-node" :title="node.label" v-text="node.label"
              :class="{ 'red': data.type == 'zd' && data.jlg == 0 }"></div>
          </el-tree>
          <div class="tree-hide-button iconfont" :class="isHide ? 'icon-xiangyou' : 'icon-xiangzuo'"
            @click="() => { isHide = !isHide }">
          </div>
        </div>
      </el-col>
      <el-col :span="isHide ? 23 : 18" :xs="24">
        <div class="app-container-table-border">
          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
            label-width="68px">
            <el-form-item label="标准清单" prop="sheetTypeName">
              <el-input v-model="queryParams.sheetTypeName" placeholder="请输入标准清单" clearable
                @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
            <el-row :gutter="10" class="mb8 cd-pr8 top-right-btn small-line-height">
              <el-col :span="1.5" v-if="canOperation() && treeInfo.parentId">
                <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
                  v-hasPermi="['cm:baContractSheets:add']">新增</el-button>
              </el-col>
              <!-- 审批完成后可编辑变更 -->
              <el-col :span="1.5" v-if="treeInfo.parentId && canChgOperation() && form.dataList.length > 0">
                <el-button v-if="canAlteration" type="primary" plain size="mini" @click="doAlteration"
                  v-hasPermi="['cm:baContractSheets:editBatch']">保存</el-button>
                <el-button v-else type="primary" plain size="mini" @click="onAlteration"
                  v-hasPermi="['cm:baContractSheets:editBatch']">变更</el-button>
              </el-col>
              <el-col :span="1.5" v-if="treeInfo.parentId && canOperation()">
                <el-button v-if="canUpdate" type="primary" plain size="mini" @click="doEditBatch"
                  v-hasPermi="['cm:baContractSheets:editBatch']">保存</el-button>
                <el-button v-else type="primary" plain size="mini" @click="onEditBatch"
                  v-hasPermi="['cm:baContractSheets:editBatch']">编辑</el-button>
              </el-col>
              <el-col :span="1.5" v-if="queryParams.zdId && (canOperation() || canChgOperation())">
                <el-button type="primary" size="mini" plain @click="onExamine">发起审批</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
                  v-hasPermi="['cm:baContractSheets:export']">导出</el-button>
              </el-col>
              <el-col :span="1.5" v-if="queryParams.zdId">
                <!--                <el-button type="text" size="mini" @click="showApproveLog()" :disabled="reportStatus == '00'">{{ reportStatusFormat() }}</el-button>-->
                <el-button type="text" size="mini" @click="handleProcess()"
                  :disabled="!(reportStatus !== '00' || chgApprovalStatus !== '00')">
                  {{ reportStatusFormat() }}
                </el-button>
              </el-col>
              <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> -->
            </el-row>
          </el-form>
          <el-form ref="tableForm" :model="form" :rules="rules" label-width="0px">
            <el-table border stripe v-loading="loading" :data="form.dataList" :span-method="objectSpanMethod"
              :summary-method="getSummaries" show-summary :max-height="tableHeight">
              <el-table-column label="序号" align="center" property="vuhao" width="50" />
              <el-table-column label="清单名称" header-align="center" property="sheetTypeName" min-width="60"
                show-overflow-tooltip>
                <template slot-scope="scope">
                  <span>{{ scope.row.sheetTypeName || "-" }}</span>
                </template>
              </el-table-column>
              <el-table-column label="规格型号名称" header-align="center" property="sheetFeaturesName" min-width="100"
                show-overflow-tooltip>
                <template slot-scope="scope">
                  <span>{{ scope.row.sheetFeaturesName || "-" }}</span>
                </template>
              </el-table-column>
              <el-table-column label="单位" align="center" property="sheetUnit" width="100">
                <template slot-scope="scope">
                  <span>{{ scope.row.sheetUnit || "-" }}</span>
                </template>
              </el-table-column>
              <el-table-column label="单价" header-align="center" align="right" property="initDanjia" width="120">
                <template slot-scope="scope">
                  <el-form-item v-if="canUpdate && scope.row.sheetId" :prop="'dataList.' + scope.$index + '.initDanjia'"
                    :rules="rules.initDanjia">
                    <el-input-number size="mini" v-model="scope.row.initDanjia" placeholder="" :precision="5"
                      :controls="false" style="width: 100%;" @change="computeInitZongjia(scope.row)" />
                    <!--                    :precision="scope.row.sheetLevel == 1 ? 4 : 3" :controls="false" style="width: 100%;"-->
                  </el-form-item>
                  <span v-else>{{ scope.row.initDanjia || "-" }}</span>
                </template>
              </el-table-column>
              <el-table-column label="数量" header-align="center" align="right" property="initRongliang" width="120">
                <template slot-scope="scope">
                  <el-form-item v-if="canUpdate && scope.row.sheetId"
                    :prop="'dataList.' + scope.$index + '.initRongliang'" :rules="rules.initRongliang">
                    <el-input-number size="mini" v-model="scope.row.initRongliang" placeholder="" :precision="3"
                      :controls="false" style="width: 100%;" @change="computeInitZongjia(scope.row)"></el-input-number>
                  </el-form-item>
                  <span v-else>{{ scope.row.initRongliang || "-" }}</span>
                </template>
              </el-table-column>
              <el-table-column label="变更数量" header-align="center" align="right" property="chgRongliang" width="120">
                <template slot-scope="scope">
                  <el-form-item v-if="canAlteration && scope.row.sheetId"
                    :prop="'dataList.' + scope.$index + '.chgRongliang'" :rules="rules.chgRongliang">
                    <el-input-number size="mini" v-model="scope.row.chgRongliang" placeholder="" :precision="3"
                      :controls="false" style="width: 100%;" @change="computeEditZongjia(scope.row)"></el-input-number>
                  </el-form-item>
                  <span v-else>{{ scope.row.chgRongliang || "-" }}</span>
                </template>
              </el-table-column>
              <el-table-column label="价税合计" header-align="center" align="right" property="initZongjia" width="140">
                <!--                <template slot-scope="scope">-->
                <!--                  <span>{{ scope.row.initZongjia || "-" }}</span>-->
                <!--                </template>-->
                <template slot-scope="scope">
                  <el-form-item v-if="canUpdate && scope.row.sheetId"
                    :prop="'dataList.' + scope.$index + '.initZongjia'" :rules="rules.initZongjia">
                    <el-input-number size="mini" v-model="scope.row.initZongjia" placeholder="" :precision="2"
                      :controls="false" style="width: 100%;" />
                  </el-form-item>
                  <span v-else>{{ scope.row.initZongjia || "-" }}</span>
                </template>
              </el-table-column>
              <el-table-column label="变更后合计" header-align="center" align="right" property="chgZongjia" width="140">
                <!--                <template slot-scope="scope">-->
                <!--                  <span>{{ scope.row.chgZongjia || "-" }}</span>-->
                <!--                </template>-->
                <template slot-scope="scope">
                  <el-form-item v-if="canAlteration && scope.row.sheetId"
                    :prop="'dataList.' + scope.$index + '.chgZongjia'" :rules="rules.chgZongjia">
                    <el-input-number size="mini" v-model="scope.row.chgZongjia" placeholder="" :precision="2"
                      :controls="false" style="width: 100%;" />
                  </el-form-item>
                  <span v-else>{{ scope.row.chgZongjia || "-" }}</span>
                </template>
              </el-table-column>
              <el-table-column label="税率(%)" header-align="center" align="right" property="sheetTaxRate" width="120">
                <template slot-scope="scope">
                  <span>{{ scope.row.sheetTaxRate || "-" }}</span>
                </template>
              </el-table-column>
              <el-table-column v-if="treeInfo.parentId && canOperation()" label="操作" width="100" align="center"
                class-name="small-padding fixed-width">
                <template slot-scope="scope">
                  <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
                    v-hasPermi="['cm:baContractSheets:edit']">修改</el-button>
                  <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                    v-hasPermi="['cm:baContractSheets:remove']">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-form>
          <!-- 修改合同清单详情对话框 -->
          <jy-dialog title="修改合同清单详情" :visible.sync="editOpen" width="600px" append-to-body>
            <el-form ref="form" :model="editForm" :rules="rules" label-width="100px">
              <el-form-item label="清单名称" prop="sheetTypeName">
                <el-input v-model="editForm.sheetTypeName" disabled />
              </el-form-item>
              <el-form-item label="规格型号名称" prop="sheetFeaturesName">
                <el-input v-model="editForm.sheetFeaturesName" disabled />
              </el-form-item>
              <el-form-item label="清单单位" prop="sheetUnit">
                <el-input v-model="editForm.sheetUnit" disabled />
              </el-form-item>
              <el-form-item label="税率(%)" prop="sheetTaxRate">
                <el-input v-model="editForm.sheetTaxRate" disabled />
              </el-form-item>
              <el-form-item label="数量" prop="initRongliang">
                <el-input-number v-model="editForm.initRongliang" placeholder="请输入数量" :precision="2" :controls="false"
                  style="width: 100%;" class="input-number" @change="countEditJshj()"></el-input-number>
                <!-- <el-input v-model="editForm.initRongliang" @change="countEditJshj" placeholder="请输入数量" /> -->
              </el-form-item>
              <el-form-item label="单价" prop="initDanjia">
                <el-input-number v-model="editForm.initDanjia" placeholder="请输入单价" :precision="5" :controls="false"
                  class="input-number" style="width: 100%;" @change="countEditJshj()"></el-input-number>
                <!-- <el-input v-model="editForm.initDanjia" @change="countEditJshj" placeholder="请输入单价" /> -->
              </el-form-item>
              <el-form-item label="价税合计" prop="initZongjia">
                <el-input v-model="editForm.initZongjia" placeholder="价税合计" />
              </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
              <el-button type="primary" @click="editFormSet">确 定</el-button>
              <el-button @click="editOpenCancel">取 消</el-button>
            </div>
          </jy-dialog>
        </div>
      </el-col>
    </el-row>
    <sheet-add ref="sheetAddRef" @callBack="handleQuery" :treeInfo="treeInfo" :standardIds="ids" @callback="getList" />
    <examine-and-approve ref="examineAndApproveRef" @callBack="handleQuery" />
    <approve-log ref="approveLogRef" />


  </div>
</template>

<script>
import { listDataBzqd, listBaContractSheets, getBaContractSheets, delBaContractSheets, addBaContractSheets, updateBaContractSheets, editBatchBaContractSheets, getApprovalStatus, checkContractSheets } from "@/api/cm/baContractSheets";
import { queryBdTree } from "@/api/base/bsBd";
import { mapGetters } from "vuex";
import ExamineAndApprove from './examine-and-approve.vue';
import SheetAdd from "./sheet-add.vue";
import decimal from "@/utils/big-decimal";
import ApproveLog from "@/views/ma/materialPlan/approve-log";

export default {
  name: "BaContractSheets",
  dicts: ['report_status'],
  components: {
    ExamineAndApprove,
    SheetAdd,
    ApproveLog
  },
  data () {
    return {
      isHide: false,
      treeList: [],
      treeInfo: {},
      defaultProps: {
        children: "children",
        label: "label"
      },
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 合同清单详情表格数据
      dataList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        contractId: undefined,
        bdId: undefined,
        zdId: undefined,
        standardId: undefined,
        initZongjia: undefined,
        initRongliang: undefined,
        initDanjia: undefined,
        initShui: undefined,
        ljbgZongjia: undefined,
        ljbgRongliang: undefined,
        ljbgDanjia: undefined
      },
      projectId: undefined,
      // 表单参数
      form: {
        dataList: []
      },
      editForm: {},
      // 表单校验
      rules: {
        // initRongliang: [{ required: true, message: "数量不能为空", trigger: "blur" }],
        // initDanjia: [{ required: true, message: "单价不能为空", trigger: "blur" }]
      },
      tableBzqdData: [],
      multipleSelection: [],
      editOpen: false,
      dayTableTotal: {},
      reportStatus: '11',
      chgApprovalStatus: '11',
      //合并表格
      columnArr: ["vuhao", "sheetTypeName", "sheetFeaturesName"],
      spanData: [],
      canUpdate: false, // 编辑
      canAlteration: false, // 变更
      tableHeight: document.documentElement.scrollHeight - 170
    };
  },
  computed: {
    ...mapGetters(["sysProjectId", "sysProjectList"])
  },
  watch: {
    sysProjectId (newVal, oldVal) {
      // 系统顶部选中项目变化
      this.changeProject(newVal);
    }
  },
  created () {
    this.changeProject();
  },
  methods: {
    changeProject (projectId = this.sysProjectId) {
      this.projectId = projectId;
      this.getBdTree();
    },
    getBdTree () {
      queryBdTree({ projectId: this.projectId, hasJl: 2 }).then((response) => {
        this.treeList = response.data;
        // 选中左侧树
        this.$nextTick(() => {
          if (this.treeList.length > 0) {
            this.$refs.tree.setCurrentKey(this.treeList[0].id);
            this.handleNodeClick(this.treeList[0]);
          } else {
            this.treeInfo = {};
            this.queryParams.bdId = null;
            this.queryParams.zdId = null;
            this.handleQuery();
          }
        });
      });
    },
    handleNodeClick (data) {
      this.treeInfo = data;
      if (data.parentId) {
        this.queryParams.bdId = data.parentId; //标段ID
        this.queryParams.zdId = data.id; //站点ID
      } else {
        this.queryParams.bdId = data.id; //标段ID
        this.queryParams.zdId = null; //站点ID
      }
      this.handleQuery();
    },
    // 合同清单审批状态
    getContractSheetsStatus () {
      if (!this.queryParams.bdId || !this.queryParams.zdId) {
        return;
      }
      const query = {
        bdId: this.queryParams.bdId,
        zdId: this.queryParams.zdId,
      };
      getApprovalStatus(query).then(res => {
        const { approvalStatus, chgApprovalStatus } = res.data || { approvalStatus: '00', chgApprovalStatus: '00' };
        this.reportStatus = approvalStatus;
        this.chgApprovalStatus = chgApprovalStatus;
      });
    },
    /** 查询合同清单详情列表 */
    getList () {
      this.loading = true;
      listBaContractSheets(this.queryParams).then((response) => {
        this.form.dataList = response.cmBaContractSheetsVos || [];
        if (this.form.dataList.length > 0) {
          this.ids = this.form.dataList.map((item) => item.standardId);
          this.getSpanData(this.form.dataList);
        } else {
          this.ids = [];
        }
        // this. = response.cmBaContractSheetsVos;
        this.dayTableTotal = response.total || {}; //总计
        this.loading = false;
        this.canUpdate = false;
        this.$forceUpdate();
      });
    },
    // 拼接合计
    getSummaries (param) {
      const { columns, data } = param;
      const sums = [];

      columns.forEach((column, index) => {
        if (index === 1) {
          sums[index] = "合计";
          return;
        }
        // sums[1] = "-";
        // sums[2] = "-";
        // sums[3] = "-";
        sums[5] = this.dayTableTotal?.rongliangTotal || "-";
        sums[6] = this.dayTableTotal?.chgRongliangTotal || "-";
        sums[7] = this.dayTableTotal?.zongjiaTotal || "-";
        sums[8] = this.dayTableTotal?.chgZongjiaTotal || "-";
        // if (index >= 5 && index <= 8) {
        //   const values = data.map(item => Number(item[column.property]));
        //   if (!values.every(value => isNaN(value))) {
        //     sums[index] = values.reduce((prev, curr) => {
        //       const value = Number(curr);
        //       if (!isNaN(value)) {
        //         return decimal.add(prev, curr);
        //       } else {
        //         return decimal.round(prev);
        //       }
        //     }, 0);
        //     sums[index] += '';
        //   } else {
        //     sums[index] = '';
        //   }
        // }
      });

      return sums;
    },

    // 计算需要合并的单元格
    getSpanData (data) {
      if (!data || data.length === 0 || !this.columnArr || this.columnArr.length === 0) {
        return;
      }
      this.spanData = [];
      for (let i = 0; i < this.columnArr.length; i++) {
        let contactDot = 0;
        const spanArr = [];
        data.forEach((item, index) => {
          // console.log(item)
          if (index === 0) {
            spanArr.push(1);
          } else {
            const isMergeRow = this.isMerge(data[index - 1], item, i);
            if (isMergeRow) {
              spanArr[contactDot] += 1;
              spanArr.push(0);
            } else {
              contactDot = index;
              spanArr.push(1);
            }
          }
        });
        this.spanData.push(spanArr);
      }

      // console.log(this.spanData)
    },
    // 是否合并
    isMerge (prevItem, item, index) {
      let ret = true;
      for (let i = 0; i <= index; i++) {
        const element = this.columnArr[i];
        if (item[element] !== prevItem[element]) {
          ret = false;
          break;
        }
      }
      return ret;
    },
    // 合并单元格
    objectSpanMethod ({ row, column, rowIndex, columnIndex }) {
      if (this.columnArr.includes(column.property)) {
        const index = this.columnArr.findIndex((item) => {
          return item == column.property;
        });
        if (this.spanData[index]) {
          if (this.spanData[index][rowIndex]) {
            return {
              rowspan: this.spanData[index][rowIndex],
              colspan: 1,
            };
          } else {
            return {
              rowspan: 0,
              colspan: 0,
            };
          }
        }
      }
    },

    editOpenCancel () {
      this.loading = false;
      this.editOpen = false;
      this.editReset();
    },
    // 表单重置
    editReset () {
      this.editForm = {
        contractId: undefined,
        bdId: undefined,
        zdId: undefined,
        sheetId: undefined,
        standardId: undefined,
        initZongjia: undefined,
        initRongliang: undefined,
        initDanjia: undefined,
        initShui: undefined,
        ljbgZongjia: undefined,
        ljbgRongliang: undefined,
        ljbgDanjia: undefined,
        ljbgShui: undefined,
        factZongjia: undefined,
        factRongliang: undefined,
        factDanjia: undefined,
        factShui: undefined,
        factWcrl: undefined,
        factWczj: undefined,
        factZfyfk: undefined,
        factKcyfk: undefined,
        factKk: undefined,
        factFkbl: undefined,
        factFk: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery () {
      this.queryParams.pageNum = 1;
      this.getList();
      this.getContractSheetsStatus();
    },
    /** 重置按钮操作 */
    resetQuery () {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd () {
      if (!this.treeInfo?.parentId) {
        this.$modal.msgError(`请先在左侧选择合同所属站点！`);
        return;
      }
      this.editReset();
      this.$refs.sheetAddRef.init();
    },
    /** 修改按钮操作 */
    handleUpdate (row) {
      // this.loading = true;
      this.editReset();
      this.editForm = JSON.parse(JSON.stringify(row));
      this.editOpen = true;
    },
    // 批量修改
    onEditBatch () {
      this.canUpdate = true;
    },
    // 批量修改提交
    doEditBatch () {
      this.buttonLoading = true;
      editBatchBaContractSheets(this.form.dataList)
        .then((response) => {
          this.$modal.msgSuccess("修改成功");
          this.getList();
        })
        .finally(() => {
          this.buttonLoading = false;
          this.canUpdate = false;
        });
    },
    // 变更
    onAlteration () {
      this.canAlteration = true;
    },
    // 变更提交
    doAlteration () {
      this.buttonLoading = true;
      editBatchBaContractSheets(this.form.dataList)
        .then((response) => {
          this.$modal.msgSuccess("变更成功");
          this.getList();
        })
        .finally(() => {
          this.buttonLoading = false;
          this.canAlteration = false;
        });
    },
    // 修改提交
    editFormSet () {
      this.buttonLoading = true;
      updateBaContractSheets(this.editForm)
        .then((response) => {
          this.$modal.msgSuccess("修改成功");
          this.editOpen = false;
          this.getList();
        })
        .finally(() => {
          this.buttonLoading = false;
        });
    },

    /** 删除按钮操作 */
    handleDelete (row) {
      const sheetIds = row.sheetId || this.ids;
      this.$modal
        .confirm('是否确认删除清单类别名称为"' + row.sheetTypeName + "规格型号名称为" + (row.sheetFeaturesName || '-') + '"的数据项？')
        .then(() => {
          this.loading = true;
          return delBaContractSheets(sheetIds);
        })
        .then(() => {
          this.loading = false;
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => { })
        .finally(() => {
          this.loading = false;
        });
    },
    /** 导出按钮操作 */
    handleExport () {
      this.download(
        "cm/baContractSheets/export",
        {
          ...this.queryParams
        },
        `合同清单_${new Date().getTime()}.xlsx`
      );
    },
    // 计算总价
    countEditJshj () {
      let a = this.editForm.initRongliang; //数量
      let b = this.editForm.initDanjia; //单价
      let c = decimal.add(a, this.editForm.chgRongliang);//变更后数量
      this.editForm.initZongjia = decimal.multiply(a, b);
      this.editForm.chgZongjia = decimal.multiply(c, b);
    },
    // 计算总价
    computeInitZongjia (row) {
      let a = Number.parseFloat(row.initRongliang); //数量
      let b = Number.parseFloat(row.initDanjia); //单价
      let c = Number.parseFloat(row.chgRongliang ? row.chgRongliang : "0"); //变更数量
      row.initZongjia = decimal.multiply(a, b);
      row.chgZongjia = decimal.multiply(a + c, b);
    },
    // 计算变更合价
    computeEditZongjia (row) {
      let a = row.chgRongliang; //变更数量
      let b = row.initRongliang; //初始数量
      let c = row.initDanjia; //单价
      // 变更合合价 = （初始数量 + 变更数量） * 初始单价
      row.chgZongjia = decimal.multiply(decimal.add(a, b), c);
    },
    /** 发起审批 */
    async onExamine () {
      try {
        // const query = {
        //   bdId: this.queryParams.bdId,
        // };
        // await checkContractSheets(query);
        const projectInfo = this.sysProjectList.find(item => item.projectId == this.projectId);
        const info = {
          projectId: this.projectId,
          projectName: projectInfo.projectName,
          bdId: this.queryParams.bdId,
          zdId: this.queryParams.zdId,
          type: this.canChgOperation() ? 'HTZDQDBGSP' : 'HTZDQDSP'
        };
        this.$refs.examineAndApproveRef.init(info);
      } catch (error) {

      }
    },
    // 是否可操作
    canOperation () {
      return this.reportStatus == '00' || this.reportStatus == '33';
    },
    // 是否和变更操作
    canChgOperation () {
      return this.reportStatus == '22' && this.chgApprovalStatus != '11';
    },
    // 状态字典翻译
    reportStatusFormat () {
      if (this.reportStatus == '22' && this.chgApprovalStatus != '00') {
        return this.selectDictLabel(this.dict.type.report_status, this.chgApprovalStatus);
      }
      return this.selectDictLabel(this.dict.type.report_status, this.reportStatus);
    },
    // 查看流转记录
    showApproveLog () {
      if (!this.form.dataList) {
        return;
      }
      let approveLog = this.form.dataList[1];
      if (!approveLog.proInsId) {
        return;
      }
      const taskForm = {
        procInsId: approveLog.proInsId,// row.procInsId, // 流程实例编号
        taskId: approveLog.taskId,//  row.taskId  // 流程任务编号
      };
      this.$refs.approveLogRef.init(taskForm);
    },
    // 跳转到审批处理页面
    handleProcess (row) {
      if (!this.form.dataList) {
        this.$message.warning("表单信息不存在！");
        return;
      }
      let approveLog = this.form.dataList[1];
      if (!approveLog.proInsId) {
        this.$message.warning("流程信息不存在！");
        return;
      }
      const processed = !(this.reportStatus != '11' && this.chgApprovalStatus != '11') && approveLog.currApproval;
      this.$router.push({
        path: '/workflow/process/detail/' + approveLog.proInsId,
        query: {
          taskId: approveLog.taskId,
          processed: processed
        }
      });
    },
  }
};
</script>
<style lang="scss" scoped>
.input-number {
  ::v-deep .el-input__inner {
    text-align: left;
  }
}
</style>
